import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

class GamePane {
    public static void showGame() {
        JFrame frame = Main.getMainFrame();
        frame.setTitle("迷宫闯关游戏 - 游戏界面");

        // 创建主面板
        JPanel mainPanel = new JPanel(new BorderLayout());
        mainPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

        // 添加游戏标题
        JLabel title = new JLabel("迷宫闯关游戏 - 游戏中");
        title.setFont(new Font("SimHei", Font.BOLD, 24));
        title.setHorizontalAlignment(JLabel.CENTER);
        mainPanel.add(title, BorderLayout.NORTH);

        // 游戏区域（这里简单用一个标签表示）
        JLabel gameArea = new JLabel("迷宫游戏区域");
        gameArea.setFont(new Font("SimHei", Font.PLAIN, 18));
        gameArea.setHorizontalAlignment(JLabel.CENTER);
        gameArea.setBorder(BorderFactory.createLineBorder(Color.BLACK));
        gameArea.setPreferredSize(new Dimension(700, 400));
        mainPanel.add(gameArea, BorderLayout.CENTER);

        // 底部按钮面板
        JPanel buttonPanel = new JPanel();
        buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

        JButton exitButton = new JButton("退出游戏");
        exitButton.setFont(new Font("SimHei", Font.PLAIN, 16));
        exitButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Menu.showMainMenu();
            }
        });

        buttonPanel.add(exitButton);
        mainPanel.add(buttonPanel, BorderLayout.SOUTH);

        // 清空并设置新的内容面板
        frame.getContentPane().removeAll();
        frame.getContentPane().add(mainPanel);
        frame.revalidate();
        frame.repaint();
    }
}